package org.adoxx.adows.client; import java.io.IOException; import java.io.PrintStream; import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; import javax.xml.rpc.ServiceException; import javax.xml.rpc.holders.IntHolder; import javax.xml.rpc.holders.StringHolder; public class RunAdoScriptFile { /** * @param args * @throws ServiceException * @throws IOException */ public static void main(String[] args) throws ServiceException, IOException { if (args.length != 1) { System.err.println("the path to the ASC file is required for the execution. No or too many arguments provided."); System.exit(1); } /* * Initialize the client, provide endpoint address of respective ADOWS * service (in the example below ADOWS has been started on port 8181 - * it http://localhost:8181) */ com.boc_eu.adoweb.adows.client.AdoWSStub binding = (com.boc_eu.adoweb.adows.client.AdoWSStub) new com.boc_eu.adoweb.adows.client.AdoWSLocator() .getAdoWS(new URL("http://localhost:8181")); /* * read the content of the AdoScript file into a string * */ String script = new String(Files.readAllBytes(Paths.get(args[0]))); /* * Initialize result holder objects * * errorCode ... returns the errorCode of the AdoScript as documented in * AdoScript section of Development Toolkit Handbook * * result ... String result from running the AdoScript */ IntHolder errorCode = new IntHolder(); StringHolder result = new StringHolder(); /* * Execute AdoScript on ADOWS */ binding.execute(script, "success", errorCode, result); /* * Prints the result into System.out * */ printResults(result.value, System.out); } private static void printResults(String value, PrintStream out) { out.println("Success? " + value); } }